﻿@model IEnumerable<RedSand.Site.Models.PropertyInfo>
<div class="panel-content">
    <div class="panel-toolbar">
        <ul>
            <li>
                @Ajax.ActionLink("Add property", "createproperty", new { count = Model == null ? 0 : Model.Count(), category = ViewBag.Category }, AdminAjaxOptions.GetProperty, new { @class = "btn-create" })
            </li>
        </ul>
    </div>
    @if (Model == null)
    {
        <div class="message warning">No property</div>
    }
    else
    {
        <table class="table-list" style="border-bottom:1px solid #ccc">
            <thead>
                <tr>
                    <th>
                        Name
                    </th>
                    <th class="center width-80">
                        Status
                    </th>
                    <th class="center width-80">
                        Control
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>
                            @item.Name
                        </td>
                        <td class="center">
                            @DropDownListHelper.GetStatusString(item.Status)
                        </td>
                        <td class="center">
                            @Ajax.ActionLink("Edit", "editproperty", new { id = item.PropertyID, count = Model.Count() }, AdminAjaxOptions.GetProperty, new { @class = "btn-edit", title = "Edit" })
                            @Ajax.ActionLink("Delete", "deleteproperty", new { id = item.PropertyID, category = item.CategoryID }, AdminAjaxOptions.DeleteProperty, new { @class = "btn-delete", title = "Delete" })
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    }
</div>
<div id="property-wrap" style="display:none"></div>
<script type="text/javascript">
    function ajax_get_property_success(data) {
        if (!isJavascriptResult(data)) {
            $('#property').dialog({
                modal: true,
                padding: '0',
                close: function () {
                    closeDialog(this);
                },
                resizable: false,
                minWidth: $('#property').width(),
                minHeight: $('#property').height()
            });
            autoZen();
        }
    }
    function ajax_get_properties_success(data) {
        if (!isJavascriptResult(data)) {
            closeDialog('#property');
            autoZen();
            getAjaxMessage();
        }
    }
</script>